package com.fanqiechaodan.factory.abstractfactory;

import com.fanqiechaodan.factory.abstractfactory.factory.AbstractFactory;
import com.fanqiechaodan.factory.abstractfactory.factory.Factory1;
import com.fanqiechaodan.factory.abstractfactory.factory.Factory2;
import com.fanqiechaodan.factory.abstractfactory.product.ProductA;
import com.fanqiechaodan.factory.abstractfactory.product.ProductB;

/**
 * @author fanqiechaodan
 * @Classname Demo
 * @Description 抽象工厂模式
 */
public class Demo {

    public static void main(String[] args) {
        // 使用具体工厂1创建产品A和产品B
        AbstractFactory factory1 = new Factory1();
        ProductA productA1 = factory1.createProductA();
        ProductB productB1 = factory1.createProductB();
        productA1.doSomething();
        productB1.doSomething();

        // 使用具体工厂2创建产品A和产品B
        AbstractFactory factory2 = new Factory2();
        ProductA productA2 = factory2.createProductA();
        ProductB productB2 = factory2.createProductB();
        productA2.doSomething();
        productB2.doSomething();
    }
}
